跳转至

分数衰减 KV 缓存:面向对话系统推理相关性优化的所有权感知内存管理

文章背景与核心概要

在基于 Transformer 的对话系统中,键值(KV)缓存对于实现高效的自回归推理至关重要。然而,现有的缓存策略往往将所有缓存条目同等对待,或者依赖于粗糙的淘汰启发式算法,这使得系统在对话主题发生演变时难以保持推理的相关性。

本文提出了“分数衰减 KV 缓存”(Fractional Decay KV-Cache, FD-KVC),这是一种创新的内存管理算法。该算法通过双通道评分机制对缓存的 KV 对进行评估:一是跟踪累积 Token 重要性的“累积注意力通道”,二是受时间衰减和强化学习启发、用于动态调整的“近因加权相关性通道”。这种机制使 FD-KVC 既能保留历史重要信息,又能快速适应主题切换。实验表明,该算法在 CPU 上运行且开销极低,在多轮对话场景中显著优于现有的 H2O 基准,在主题适应速度和多样性方面表现卓越。


摘要

中文翻译: 键值(KV)缓存对于基于 Transformer 的对话系统中的高效自回归推理至关重要,但现有的策略要么统一对待所有缓存条目,要么应用粗糙的淘汰启发式算法,导致在对话主题演变时无法有效适应。我们提出了分数衰减 KV 缓存(FD-KVC),这是一种为每个缓存 KV 对维护双通道评分机制的新型算法:一个跟踪累积重要性的累积注意力通道(类似于 H2O),以及一个受时间衰减和强化学习启发更新的近因加权相关性通道。这种组合使 FD-KVC 既能保留历史上重要的 Token,又能在对话主题转换时快速适应。由所有权损失函数驱动的自适应学习率确保了收敛且不会产生震荡。FD-KVC 完全在 CPU 上运行,开销可忽略不计。在五个包含 600 场对话的多轮对话场景中,FD-KVC 在复合后期对齐指标上比最先进的重击手(heavy-hitter)基准 H2O 高出 +6.7%,在主题切换方面提升了 +127%,在渐进式演变方面提升了 +87%,在混合主题对话方面提升了 +30%。FD-KVC 适应新主题的速度比 H2O 快 3.6 倍,并在所有方法中实现了最高的主题多样性(80.6%)。消融研究证实了每个组件的贡献。

Key-value (KV) caching is essential for efficient autoregressive inference in transformer based dialog systems, yet existing strategies treat all cached entries uniformly or apply coarse eviction heuristics that fail to adapt as dialog topics evolve. We propose Fractional Decay KV-Cache (FD-KVC), a novel algorithm that maintains a dual-channel scoring mechanism for each cached KV pair: a cumulative attention channel that tracks aggregate importance (akin to H2O), and a recency-weighted relevance channel governed by temporal decay and reinforcement-inspired updates. The combination enables FD-KVC to both preserve historically important tokens and rapidly adapt when dialog topics shift. An adaptive learning rate driven by an ownership loss function ensures convergence without oscillation. FD-KVC operates entirely on CPU with negligible overhead. Across five diverse multi-turn dialog scenarios with 600 dialogs each, FD-KVC outperforms H2O, the state-of-the-art heavy-hitter baseline, by +6.7% on composite late-turn alignment, with improvements of +127% on topic-shift, +87% on gradual evolution, and +30% on mixed-topic dialogs. FD-KVC adapts to new topics 3.6X faster than H2O and achieves the highest topic diversity (80.6%) across all methods. Ablation studies confirm the contribution of each component.


关键亮点与性能

中文翻译: * 后期对齐(Late-Turn Alignment): 在复合指标上比 H2O 表现高出 +6.7%。 * 主题转换场景: * 在突发主题切换上提升 +127%。 * 在渐进式主题演变上提升 +87%。 * 在混合主题对话上提升 +30%。 * 适应性: 适应新主题的速度比 H2O 快 3.6 倍。 * 多样性: 在所有评估方法中实现了最高的主题多样性,达到 80.6%。 * 效率: 完全在 CPU 上运行,计算开销极小。

  • Late-Turn Alignment: Outperforms H2O by +6.7% on composite metrics.
  • Topic Transition Scenarios:
  • +127% improvement on abrupt topic-shifts.
  • +87% improvement on gradual topic evolutions.
  • +30% improvement on mixed-topic dialogs.
  • Adaptability: Adapts to new topics 3.6× faster than H2O.
  • Diversity: Achieves the highest topic diversity at 80.6% among evaluated approaches.
  • Efficiency: Runs completely on CPU with minimal computational overhead.

访问与资源